import routerList from "./routerconfig";
import {BrowserRouter,Routes,Route,Navigate} from "react-router-dom"
import {Suspense} from "react"
let RouterView = ()=>{
    let renderRoute = (routerList)=>{
        return routerList.map((item,index)=>{
            return item.path ? <Route path={item.path} key={index} element={<item.element></item.element>}>
                 {
                     item.children && renderRoute(item.children)
                 }
            </Route>:
            <Route path={item.from} key={index} element={<Navigate to={item.to}></Navigate>}></Route>
        })
    }
    return (
        <BrowserRouter>
         <Suspense fallback={<div>...loading</div>}>
            
                 <Routes>
                    {
                       renderRoute(routerList)
                    }
 
             </Routes>
            

         </Suspense>
        </BrowserRouter>
    )
}
export default RouterView